#ifndef head_h
#define head_h
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class node{
  public: string name;
            vector<node*> node_list;
          node(string name1){name=name1;}
            
};
class terminal_node: public node{
public: string type;
        string value;
    typedef node super;
    terminal_node(string type1):super("terminal")
            {  type=type1; 
               value="";}
    terminal_node(string type1, string value1):super("terminal")
            {  type=type1; 
               value=value1;}
};
class DFS{
public:
    void print(node* n){
        cout<<endl;
        cout<<n->name<<"  ";
        cout<<endl;
    
        if(!n->node_list.empty()){
            for(int i=0; i<n->node_list.size();i++){
                print(n->node_list[i]);
            }
        }
    }
    
    void rebuild(node* n){
        if(n->name=="terminal")
            if(((terminal_node *)n)->value.size()!=0){
                cout<<"("<<((terminal_node *)n)->type<<")"<<((terminal_node *)n)->value<<"  ";
            }else
                cout<<((terminal_node *)n)->type<<"  ";
        if(!n->node_list.empty()){
            for(int i=0; i<n->node_list.size();i++){
                rebuild(n->node_list[i]);
            }
        }
    }
    
};
//class program_node: public node{
 

#endif
